/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.folha.dao;

import br.com.folha.entity.TipoContrato;
import br.com.folha.utilidades.HibernateUtil;
import java.io.Serializable;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author marceloml
 */
public class TipoContratoDao implements Serializable{
    
    private static final long serialVersionUID = 1L;
    
    public List<TipoContrato> listaTipoContrato(Object t) {
        Session sessao = HibernateUtil.getSessionFactory();
        Criteria criteria = sessao.createCriteria(t.getClass());          
        List lista = criteria.list();
        sessao.close();
        return lista;      
    }    
    
    public TipoContrato getById(int id)
    { 
       Session sessao = HibernateUtil.getSessionFactory();
       Query query = sessao.createQuery("FROM TipoContrato WHERE id = :id");               
       query.setParameter("id", id);        

       return (TipoContrato) query.uniqueResult();
    }      
    
}
